//
//  EFReturnReasonCell.m
//  EnjogFood
//
//  Created by 王芳 on 17/6/11.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFReturnReasonCell.h"
#import "EFReturnReasonItem.h"

@interface EFReturnReasonCell ()
@property (strong, nonatomic) UILabel *contentLabel;
@property (strong, nonatomic) UIView *line;
@end
@implementation EFReturnReasonCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self initUI];
    }
    return self;
}

- (void)initUI{
    [self.contentView addSubview:self.contentLabel];
    [self.contentView addSubview:self.line];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.line.left = 20;
    self.line.bottom = self.height;
}

- (void)setObject:(EFReturnReasonItem *)item{
    self.contentLabel.text = item.content;
    self.contentLabel.width = kScreenWidth - 2 * 20;
    [self.contentLabel sizeToFit];
    
    self.contentLabel.left = 20;
    self.contentLabel.top = 15;
}

- (UILabel *)contentLabel{
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = [UIFont systemFontOfSize:13];
        _contentLabel.textColor = kBlack333;
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}


+ (CGFloat)returnReasonCellHeight:(EFReturnReasonItem *)item{
    UILabel *tempLabel = [[UILabel alloc] init];
    tempLabel.font = [UIFont systemFontOfSize:13];
    tempLabel.numberOfLines = 0;
    tempLabel.text = item.content;
    tempLabel.width =  kScreenWidth - 2 * 20;
    [tempLabel sizeToFit];
    
    return tempLabel.height + 2*15;
    
}

- (UIView *)line{
    if (!_line) {
        _line = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth - 2*20, 1)];
        _line.backgroundColor = RGBCOLOR(0xececec);
    }
    return _line;
}

@end
